package cn.itcast.bos.service.base.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.itcast.bos.dao.base.TakeTimeRepository;
import cn.itcast.bos.domain.base.TakeTime;
import cn.itcast.bos.service.base.TakeTimeService;

@Service
@Transactional
public class TakeTimeServiceImpl implements TakeTimeService {

	@Autowired
	private TakeTimeRepository takeTimeRepository;

	@Override
	public List<TakeTime> taketime_findAll() {
		return takeTimeRepository.findAll();
	}

	@Override
	public Page<TakeTime> takeTimePageQuery(Pageable pageable) {
		return takeTimeRepository.findAll(pageable);
	}

	@Override
	public void takeTimeSave(TakeTime takeTime) {

		takeTimeRepository.save(takeTime);
	}

	@Override
	public void updateStatusDel(String ids) {
		String[] idStr = ids.split(",");
		for (String string : idStr) {
			Integer id = Integer.parseInt(string);
			takeTimeRepository.updateStatusDel(id);
		}
	}

	@Override
	public void updateStatusBack(String ids) {
		String[] idStr = ids.split(",");
		for (String string : idStr) {
			Integer id = Integer.parseInt(string);
			takeTimeRepository.updateStatusBack(id);
		}
	}

}
